package com.tuanzi.loan.web.lazy.system;

import org.springframework.data.domain.Page;

import com.tuanzi.loan.business.entity.CurrentUser;
import com.tuanzi.loan.core.lazy.BaseLazyDataModel;
import com.tuanzi.loan.core.util.SpringContextHolder;
import com.tuanzi.loan.core.vo.PageSearcher;
import com.tuanzi.loan.workflow.service.WorkflowTaskService;
import com.tuanzi.loan.workflow.vo.TaskSearchRequest;
import com.tuanzi.loan.workflow.vo.TaskSearchResponse;

/**
 * @author Ray 2017/09/21
 */
public class DoneTaskLazyDataModel extends BaseLazyDataModel<TaskSearchRequest, TaskSearchResponse> {

	private static final long serialVersionUID = 9143007553234885156L;

	private WorkflowTaskService workflowTaskService = SpringContextHolder.getBean(WorkflowTaskService.class);

	public DoneTaskLazyDataModel(TaskSearchRequest searchRequest) {
		super(searchRequest);
	}

	@Override
	protected Page<TaskSearchResponse> doLoad(PageSearcher<TaskSearchRequest> pageSearcher) {
		pageSearcher.getSearchCondition().setAccount(CurrentUser.get().getAccount());
		return workflowTaskService.listDoneTask(pageSearcher);
	}
}
